import request from "@/utils/request";
import Qs from "qs";

// 广告表格
export function getAdTableData(params) {
  return request({
    method: "GET",
    url: "/news/advert/detail/list",
    params,
    paramsSerializer: (params) => {
      return Qs.stringify(params, { indices: false });
    },
  });
}

// 查询当前需要渲染的广告
export function queryCurrentRender(params) {
  return request({
    method: "GET",
    url: "/news/advert/detail/queryCurrentRender",
    params,
  });
}

// 创建广告详情
export function creatAdvert(data) {
  return request({
    method: "POST",
    url: "/news/advert/detail/create",
    data,
  });
}

// 修改广告详情
export function updateAdvert(data) {
  return request({
    method: "PUT",
    url: "/news/advert/detail/change",
    data,
  });
}

// 修改广告详情状态
export function updateAdvertStatus(data) {
  return request({
    method: "PUT",
    url: "/news/advert/detail/changeStatus",
    params: data,
  });
}

// 删除广告详情
export function delAdvertById(data) {
  return request({
    url: "/news/advert/detail/deleteByIds",
    method: "DELETE",
    params: {
      advertDetailIds: data,
    },
    paramsSerializer: (params) => {
      return Qs.stringify(params, { indices: false });
    },
  });
}

// 查询年月查询广告投放时间线
export function queryAdTimeLineByYearMonth(params) {
  console.log(params);
  return request({
    url: "/news/advert/detail/queryByTime",
    params,
  });
}

// 通过id查询广告
export function queryAdById(params) {
  return request({
    method: "GET",
    url: "/news/advert/detail/queryById",
    params,
  });
}

// 查询广告时间刻度
// GET /news/advert/detail/queryTimeScale
// 接口ID：14480189
// 接口地址：https://www.apifox.cn/web/project/708508/apis/api-14480189
export function queryTimeScale(params) {
  return request({
    method: "GET",
    url: "/news/advert/detail/queryTimeScale",
    params,
  });
}
